<?php
/* explain:
 * Project:     
 * File:        Job.php
 *
 * @ link 		http://www.../lib/
 * @ Email		ldmmyx@hotmail.com
 * @ copyright 	2007  Ling Deming
 * @ author 	ivan.ling  Ling Deming
 * @ version 	1.0
 *
 */
include_once(dirname(__FILE__) . "/../utils/CommonUtils.php");

class MenuGroupImpl extends CommonUtils
{
	
	
	function __construct($DBTag = 'system')
	{
		parent::__construct();
		
		$this->DBTag 	= $DBTag;
	}

	/* get data via ID
	 *
	 * @param  int    id
	 * @return mixed  false:
	 */
	public function getById($id)
	{
		$sql = "SELECT * FROM menu_groups WHERE id = $id";
		
		return $this->getRow($this->DBTag, $sql);	
	}

	/* 
	 *
	 * @param  string 	strOrders	
	 * @param  string  	name 	
	 * @param  string 	namecn 
	 * @return boolean 	true or fail
	 * 
	 */
	public function add($strOrders, $name, $status = 'normal')
	{
		$sql = "INSERT INTO menu_groups SET orders='$strOrders', name = '$name', status='$status'";
		
		return $this->insert($this->DBTag, $sql);
	}
		
	/* modify menu
	 *
	 * @param  string 	id			modify menu id
	 * @param  string 	strOrders	
	 * @param  string  	name 	
	 * @param  string 	namecn 
	 * @return boolean 	true or fail
	 */
	public function edit($id, $strOrders, $name)
	{
		$sql = "UPDATE menu_groups SET orders='$strOrders', name = '$name' WHERE id='$id'";
		
		return $this->update($this->DBTag, $sql);
	}
			
	/* delete menu
	 *
	 * @param  int    	id
	 * @param  return 	boolean
	 */
	public function delete($id)
	{
		$sql = "DELETE FROM menu_groups WHERE id = $id";
		
		return $this->update($this->DBTag, $sql);
	}
	
	public function select($where, $order, $page, $discount, $url = '')
	{		
		return $this->getHash($this->DBTag, "SELECT id, name FROM menu_groups");	
	}
}
?>
